<%-- Copyright (C) 2009 WorkSmart Labs, Inc. --%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="com.wsl.HealthChallenge.models.*" %>

<%-- 
    This is a simple JSP template for creating a challenge. It lets you input a name
    for the challenge, an id that will be part of the URL and a small description.  
    @author mark
--%>

<html>
  <head>
    <%
      ContestEntry contestEntry = (ContestEntry) request.getAttribute("challenge");
      Collection<UserStats> userStats = contestEntry.getUserStats().values();
      String name = contestEntry.getName();
      String id = contestEntry.getId();
      boolean justCreated = (Boolean) request.getAttribute("justCreated");
    %>
    <title><%=name%> - WALK2.me</title>
    <link rel="stylesheet" href="/static/style.css" type="text/css" media="all"/>
  </head>
  <body>
    <div class="title"><%=name%> - WALK2.me</div><br/>
    <div class="subtitle">Administrator Page</div><br/>
    <% if (justCreated) { %>
      <div class="slim-heading">You've created the contest!  Time to send the invitations!</div>
      <br/><br/>
    <% } %>
    <div class="slim-heading">Invite People to Join</div>
    <div class="slim">
      Just send this contest link to anyone you want to invite. To participate, all 
      they need is a Gmail e-mail address!<br/><br/>
      <a href="http://www.walk2.me/<%=id%>">http://www.walk2.me/<%=id%></a>
    </div><br/>

    <div class="slim-heading">Administer Contest</div>
    <div class="slim">
        Once people accept your invitations, this section will let you monitor the contest, 
        manage participants, and fix up any mistakes. It's your task to set the prizes, 
        discuss any extra rules, and make sure everyone is having fun!

        <br/><br/>Remember: with great power, comes great responsibility.
        <% if (userStats != null && !userStats.isEmpty()) { %>
        <br/> Users signed up:
        <table>
            <% for (UserStats entry : userStats) { %>
                <tr><td style="width:250px;">
                <%=entry.getName()%>
                </td><td><%=entry.getScore()%> calories</td>
              </tr>
            <% } %>
        </table>
       <% } %>
        <br/><br/>
    </div>
    <div class="slim-heading">Update Contest Details</div>
    <div class="slim">
      <form action="" method="get">
        <table>
        <tr><td style="width: 250px;">Contest name:</td>
            <td><input type="text" name="name" value="<%=name%>"/></td>
        </tr>
        <tr><td>Contest id: <i>http://www.walk2.me/</i></td>
            <td><input type="text" value="<%=id%>" disabled/>
            <input type="hidden" name="id" value="<%=id%>"/></td>
        </tr>
        <tr><td>Contest start date: </td>
             <td><input type="text" name="start_date" value="<%=contestEntry.getStartDate()%>"/></td>
        </tr>
        <tr><td>More info link (optional): </td>
             <td><input type="text" name="more_info_url" value="{{ more_info_url }}"/></td>
        </tr>
        </table>
        <input class="create-button" type="submit" value="Update Contest"/>
      </form>
    </div>
  </body>
</html>
